package com.kaluli.project.utils;

import java.util.Calendar;
import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DateOprator
{
	private static final Log log = LogFactory.getLog(DateOprator.class);
	
	/**
	 * 获取指定日期的下一天
	 * 
	 * @param currDate
	 * @return
	 */
	public static Date getNextDay(Date currDate)
	{
		Calendar c = Calendar.getInstance();
		c.setTime(currDate);
		c.add(Calendar.DAY_OF_YEAR, 1);
		return c.getTime();
	}
	
	/**
	 * 获取指定日期的前一天
	 * 
	 * @param currDate
	 * @return
	 */
	public static Date getPreDay(Date currDate)
	{
		Calendar c = Calendar.getInstance();
		c.setTime(currDate);
		c.add(Calendar.DAY_OF_YEAR, -1);
		return c.getTime();
	}
	
	/**
	 * 获取指定日期的前一个月的日期
	 * 
	 * @param currDate
	 * @param amount
	 * @return
	 */
	public static Date getNextMonthByLength(Date currDate, Integer amount)
	{
		Calendar c = Calendar.getInstance();
		c.setTime(currDate);
		c.add(Calendar.MONTH, amount);
		return c.getTime();
	}
	
	/**
	 * 获取指定日期的前一个月的日期
	 * 
	 * @param currDate
	 * @param amount
	 * @return
	 */
	public static Date getPrevMonthByLength(Date currDate, Integer amount)
	{
		Calendar c = Calendar.getInstance();
		c.setTime(currDate);
		c.add(Calendar.MONTH, (amount * -1));
		return c.getTime();
	}
	
	
}
